#!/bin/bash

if [ ! $# == 2 ]; then
  echo "Usage: $0 <INSTITUTION_ACRONYM> <INSTITUTION_CODE>"
  echo "Example: $0 ufg 10"
  exit 0
fi

sed -i s/ufg2/$1/g /etc/hostname
hostname -F /etc/hostname

sed -i s/ufg2/$1/g /etc/hosts
sed -i s/10.11.11./10.$2.11./g /etc/hosts

service dnsmasq stop
echo "" > /var/lib/misc/dnsmasq.leases
sed -i s/10.11.11./10.$2.11./g /etc/network/interfaces
sed -i s/172.16.10./172.16.$2./g /etc/network/interfaces
sed -i s/10.11.11./10.$2.11./g /etc/dnsmasq.conf

sed -i s/ufg2/$1/g /tftpboot/pxelinux.cfg/omf-5.4

service omf-aggmgr-5.4 stop
sed -i s/ufg2/$1/g /etc/omf-aggmgr-5.4/omf-aggmgr.yaml
sed -i s/10.11.11./10.$2.11./g /etc/omf-aggmgr-5.4/available/frisbee.yaml
sed -i s/10.11.11./10.$2.11./g /etc/omf-aggmgr-5.4/available/saveimage.yaml
sed -i s/ufg2/$1/g /etc/omf-expctl-5.4/omf-expctl.yaml
sed -i s/ufg2/$1/g /usr/share/omf-expctl-5.4/omf-resctl.yaml.island
sed -i s/ufg2/$1/g /etc/skel/hello_world.rb
sed -i s/10.11.11./10.$2.11./g /etc/skel/hello_world.rb
sed -i s/192.168.11./192.168.$2./g /etc/skel/hello_world.rb
sed -i s/ufg2/$1/g /etc/skel/hello_world_wireless.rb
sed -i s/10.11.11./10.$2.11./g /etc/skel/hello_world_wireless.rb
sed -i s/192.168.11./192.168.$2./g /etc/skel/hello_world_wireless.rb

sed -i s/10.10.0./10.$2.0./g /etc/ldap.conf

sed -i s/omf-ufg2/omf-$1/g /etc/postfix/main.cf
